﻿using System;
using System.Collections.Generic;
using System.Text;
using HAVNet.Core;


namespace HAVNet.Intros.AST
{
    public class ASTExprPrimName : ASTExprPrim
    {
        ASTTypeArgumentList _afterDotTargs      = null;
        ASTTypeArgumentList _afterDblColonTargs = null;

        public string ident             { get; set; }
        
        public string afterDblColonIdent{ get; set; }
        public ASTTypeArgumentList afterDblColonTargs { get { if (_afterDblColonTargs == null) _afterDblColonTargs = new ASTTypeArgumentList(); return _afterDblColonTargs; } }

        public string afterDotIdent     { get; set; }
        public ASTTypeArgumentList afterDotTargs        { get { if (_afterDotTargs == null) _afterDotTargs = new ASTTypeArgumentList(); return _afterDotTargs; } }

        public override string ToString()
        {
            if (string.IsNullOrEmpty(afterDblColonIdent) && string.IsNullOrEmpty(afterDotIdent))
                return ident +
                    Lazy.toStringNN(_tails, "");
            else if (string.IsNullOrEmpty(afterDotIdent))
                return
                    ident   +
                    "::"    + afterDblColonIdent + Lazy.toStringNN(_afterDblColonTargs, "") +
                    Lazy.toStringNN(_tails, "");
            else
                return
                    ident   +
                    "::"    + afterDblColonIdent+ Lazy.toStringNN(_afterDblColonTargs, "") +
                    "."     + afterDotIdent     + Lazy.toStringNN(_afterDotTargs     , "") +
                    Lazy.toStringNN(_tails, "");

        }
    }
}
